package com.allwees.bs.module.pms.rest;

import com.allwees.bs.module.core.annotation.PrintLog;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.allwees.bs.core.modelbase.vo.R;
import com.allwees.bs.module.core.rest.BoCrudApi;
import com.allwees.bs.module.pms.dto.CategoryDto;
import com.allwees.bs.module.pms.entity.Category;
import com.allwees.bs.module.pms.req.query.CategoryQueryReq;
import com.allwees.bs.module.pms.service.CategoryService;
import me.zhengjie.annotation.AnonymousAccess;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@PrintLog
@RestController
@RequestMapping("/backstage/api/pms/category")
public class CategoryApi extends BoCrudApi<Category, CategoryService> {

	@GetMapping("page")
	@AnonymousAccess
	public R page(Page<Category> page, CategoryQueryReq req) {
		return super.page(page, req);
	}

	@PostMapping("/sort")
	public R sort(@Validated @RequestBody CategoryDto dto) {
		boService.sort(dto);
		return R.ok();
	}
}
